package com.nana.petadventure.ui.guide
{
	import com.nana.framework.ui.PSprite;
	
	public class LoadingTips extends PSprite
	{
		private var guideListArray:Array;
		private var littleTip:TextField;
		private var guideTextString:String;
		private var guideText:TextField;
		private var guideBackGround:DisplayObject;
		private var guideSp:Sprite;
		private var guideWeight:Array;
		
		public function LoadingTips(){
			this.littleTip = TextFieldUtil.creatNormalTextField(UIManager.getLanguageManager().getText("littleTip"), 16);
			this.guideBackGround = (Dll.getInstance().getDisplayObjectByName(ResourceConst.LOADING_TIPS_GROUND) as DisplayObject);
			this.guideSp = new Sprite();
			super();
			this.guideListArray = AppModelList.getInstance().configModel.GuideDescribeList;
			var _local1:int = this.guideWeightInt();
			this.guideSp.addChild(this.guideBackGround);
			this.guideSp.addChild(this.littleTip);
			this.guideText = TextFieldUtil.creatNormalTextField("", 16, 0xFFFF00);
			this.init(_local1);
			this.guideSp.addChild(this.guideText);
		}
		private function init(_arg1:int):void{
			if (_arg1 == -1){
				return;
			};
			this.guideTextString = this.guideListArray[_arg1].guideContent;
			this.guideText.htmlText = this.guideTextString;
			this.guideText.width = (this.guideText.textWidth + 5);
			this.guideBackGround.width = ((this.littleTip.width + this.guideText.width) + 50);
			this.guideText.y = (this.guideBackGround.y + 5);
			this.littleTip.y = this.guideText.y;
			this.littleTip.x = (this.guideBackGround.x + (((this.guideBackGround.width - this.littleTip.width) - this.guideText.width) / 2));
			this.guideText.x = (this.littleTip.x + this.littleTip.textWidth);
			addChild(this.guideSp);
		}
		public function randomTip():void{
			var _local1:int = this.guideWeightInt();
			this.init(_local1);
		}
		private function guideWeightInt():int{
			var _local1:int;
			var _local2:int;
			if (this.guideWeight == null){
				this.guideWeight = [];
				_local1 = 0;
				_local2 = 0;
				while (_local2 < this.guideListArray.length) {
					_local1 = this.guideListArray[_local2].selectWeight;
					this.guideWeight.push(_local1);
					_local2++;
				};
			};
			return (MathUtil.calRandom(this.guideWeight));
		}
	}
}